package com.dm.wallpaper.library.fraction;

import com.dm.wallpaper.library.ResourceTable;
import ohos.aafwk.ability.fraction.Fraction;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.LayoutScatter;
import ohos.agp.components.Text;
import ohos.bundle.BundleInfo;
import ohos.rpc.RemoteException;

public class AboutFraction extends Fraction {
    Component component;

    @Override
    protected Component onComponentAttached(LayoutScatter scatter, ComponentContainer container, Intent intent) {
        component = scatter.parse(ResourceTable.Layout_fraction_about_layout, null, false);
        return component;
    }

    @Override
    protected void onActive() {
        super.onActive();
        try {
            BundleInfo bundleInfo = getFractionAbility().getBundleManager().getBundleInfo(getFractionAbility().getBundleName(), 0);
            ((Text) component.findComponentById(ResourceTable.Id_version)).setText(bundleInfo.getVersionName());
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }
}
